<%@page import="Cl.*"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>通讯录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<style type="text/css">
		table tr td{text-align:center;}
		a {text-decoration:none;}
		a:link {color: #000000}     /* 未访问的链接 */
		a:visited {color: #000000}  /* 已访问的链接 */
		a:hover {color: #000000}    /* 当有鼠标悬停在链接上 */
		a:active {color: #000000}   /* 被选择的链接 */
	</style>
  </head>
  
  <body>
  <form action = "" method = "post">
  	<input type = "text" placeholder = "请输入搜索条件" name = "cond">
  	<input type = "submit" value = "搜索">
  	<input type = "button" onclick = "add(add)" value = "添加">
  </form>
  <table border="1" style="border-collapse:collapse;">
  	<tr>
  		<th>姓名</th><th>电话</th><th>E-mail</th><th>备注</th><th>操作</th>
  	</tr>
  
    <%
    	MemoCl op = new MemoCl(); 
    	//op.delById("6");
    	String cond = request.getParameter("cond");
    	String sql = "";
    	if(!(cond == null || cond.equals("")))
    		sql = "WHERE name LIKE '%"+cond+"%' OR tel LIKE '%"+cond+"%' OR remark LIKE '%"+cond+"%' OR email LIKE '%"+cond+"%'";
    	ArrayList<MemoBean> memo = op.getList(sql);
    	for(int i = 0;i<memo.size();i++)
    	{
    		MemoBean tmp = memo.get(i);
    		%>
    		<tr>
    			<td><%=tmp.getName() %></td>
    			<td><%=tmp.getTel() %></td>
    			<td><%=tmp.getEmail() %></td>
    			<td><%=tmp.getRemark() %></td>
    			<td>
    				<a href = "Add_Up.jsp?tid=<%=tmp.getId()%>">修改</a>
    				<a href = "CL.jsp?do=del&&tid=<%=tmp.getId() %>">删除</a>
    			</td>
    		</tr>
    		<%
    	}
    %>
    </table>
    
  </body>
  <script>
    function add()
    {
    	window.location = "Add_Up.jsp?tid=0";
    }
    
  </script>
</html>
